package com.ktwlsoft.archivemanage.domain.dao.entity;

import com.ktwlsoft.archivemanage.service.utils.SnowFlake;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;

import java.util.Date;

@ApiModel("通用操作日志")
@Setter
@Getter
public class OperationLog {

    @ApiModelProperty("id")
    private Long id = SnowFlake.getNextId();

    @ApiModelProperty("操作类型")
    private OperationLog.OperationType type;

    @ApiModelProperty("路径")
    private String route;

    @ApiModelProperty("操作人")
    private String operator;

    @ApiModelProperty("操作人Id")
    private Long operatorId;

    @ApiModelProperty("id地址")
    private String ip;

    @ApiModelProperty("操纵时间")
    private Date operateTime;

    @ApiModelProperty("业务类型")
    private OperationLog.BusinessType businessType;

    @ApiModelProperty("描述")
    private String description;

    public enum OperationType {
        @ApiModelProperty("添加")
        ADD,
        @ApiModelProperty("编辑")
        EDIT,
        @ApiModelProperty("删除")
        DELETE,
        @ApiModelProperty("查看")
        CHECK,
        @ApiModelProperty("数据对比")
        DATE_COMPARE,
        @ApiModelProperty("设置")
        SET,
        @ApiModelProperty("验证")
        VERIFY,
        @ApiModelProperty("禁用")
        DISABLE,
        @ApiModelProperty("启用")
        ENABLE,
        @ApiModelProperty("启用/禁用")
        ENABLE_DISABLE,
        @ApiModelProperty("权限")
        AUTHORISE,
        @ApiModelProperty("密码")
        PASSWORD,
        @ApiModelProperty("复制")
        COPY,
        @ApiModelProperty("导出")
        EXPORT,
        @ApiModelProperty("批量导出")
        EXPORT_BATCH,
        @ApiModelProperty("撤销")
        CANCEL,
        @ApiModelProperty("移交")
        TRANSFER,
        @ApiModelProperty("撤销移交")
        TRANSFER_CANCEL,
        @ApiModelProperty("差异分析")
        DIFF_ANALYSIS,
        @ApiModelProperty("登录")
        LOGGING,
        @ApiModelProperty("退出")
        LOGGING_OUT,
        @ApiModelProperty("归档")
        ARCHIVE,
        @ApiModelProperty("取消归档")
        CANCEL_ARCHIVE
    }

    public enum BusinessType{
        @ApiModelProperty("业务")
        BUSINESS,
        @ApiModelProperty("系统设置")
        SYSTEM,
        @ApiModelProperty("登录退出")
        LOGGING
    }

    public OperationLog(){

    }

    public OperationLog(OperationType type, String route, String operator, Long operatorId, String ip, Date operateTime, BusinessType businessType, String description) {
        this.type = type;
        this.route = route;
        this.operator = operator;
        this.operatorId = operatorId;
        this.ip = ip;
        this.operateTime = operateTime;
        this.businessType = businessType;
        this.description = description;
    }
}